//
//  TouchContent.m
//  GestIT
//
//  Created by Davide Spano on 27/08/12.
//  Copyright (c) 2012 Davide Spano. All rights reserved.
//

#import "TouchContent.h"
#import "TouchEventArgs.h"
#import "TouchToken.h"

@class TouchEventArgs, TouchToken;

@implementation TouchContent

@synthesize type, touchId;

- (id) init{
    self = [super init];
    return self;
}

- (id) initWithTypeId:(TouchType)t :(int)tId{
    self = [super init];
    if(self){
        self.type = t;
        self.touchId = tId;
    }
    
    return self;
}

- (bool) accepts:(ExpEventArgs *)args :(Token *)token{
    if(! ([args class] == [TouchEventArgs class])){
        return false;
    }
    
    TouchEventArgs* targs = (TouchEventArgs*) args;
    if(targs.Id != self.touchId){
        return false;
    }
    if(targs.type != self.type){
        return false;
    }
    
    return true;
    
}

- (bool) consume:(ExpEventArgs *)args :(Token *)token{
    if(!([args class] == [TouchEventArgs class] || !([token class] == [TouchToken class]))){
        return false;
    }
    
    TouchEventArgs* targs = (TouchEventArgs*) args;
    TouchToken* tToken = (TouchToken*) token;
    [tToken save:targs];
    return true;
}


@end
